<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>peach.fuzzy.control.Parametric</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="peach-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a href="http://code.google.com/p/peach">Peach - Computational Intelligence for Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="peach-module.html">Package&nbsp;peach</a> ::
        <a href="peach.fuzzy-module.html">Package&nbsp;fuzzy</a> ::
        <a href="peach.fuzzy.control-module.html">Module&nbsp;control</a> ::
        Class&nbsp;Parametric
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="peach.fuzzy.control.Parametric-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Parametric</h1><p class="nomargin-top"><span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_peach_fu_5" name="uml_class_diagram_for_peach_fu_5">
<area shape="rect" id="node1" href="peach.fuzzy.control.Sugeno-class.html" title="Sugeno is an alias to Parametric" alt="" coords="487,153,567,191"/>
<area shape="rect" id="node7" href="peach.fuzzy.control.Parametric-class.html#rules" title="Property that returns the list of decision rules. Not writable" alt="" coords="17,31,1035,49"/>
<area shape="rect" id="node7" href="peach.fuzzy.control.Parametric-class.html#__init__" title="Creates and initializes the controller." alt="" coords="17,52,1035,71"/>
<area shape="rect" id="node7" href="peach.fuzzy.control.Parametric-class.html#add_rule" title="Adds a decision rule to the knowledge base." alt="" coords="17,71,1035,89"/>
<area shape="rect" id="node7" href="peach.fuzzy.control.Parametric-class.html#eval" title="Evaluates one decision rule in this controller" alt="" coords="17,89,1035,108"/>
<area shape="rect" id="node7" href="peach.fuzzy.control.Parametric-class.html#__call__" title="Apply the controller to the set of input variables" alt="" coords="17,108,1035,127"/>
<area shape="rect" id="node2" href="peach.fuzzy.control.Parametric-class.html" title="Basic Parametric controller" alt="" coords="5,6,1045,133"/>
</map>
  <img src="uml_class_diagram_for_peach_fu_5.gif" alt='' usemap="#uml_class_diagram_for_peach_fu_5" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<p>Basic Parametric controller</p>
<p>This class implements a standard parametric (or Takagi-Sugeno) controller. A
controller based on fuzzy logic has a somewhat complex behaviour, so it is
not explained here. There are numerous references that can be consulted.</p>
<p>It is essential to understand the format that decision rules must follow to
obtain correct behaviour of the controller. A rule is a tuple given by:</p>
<pre class="rst-literal-block">
((mx0, mx1, ..., mxn), (a0, a1, ..., an))
</pre>
<p>where <tt class="rst-docutils literal">mx0</tt> is a membership function of the first input variable, <tt class="rst-docutils literal">mx1</tt>
is a membership function of the second input variable and so on; and <tt class="rst-docutils literal">a0</tt>
is the linear parameter, <tt class="rst-docutils literal">a1</tt> is the parameter associated with the first
input variable, <tt class="rst-docutils literal">a2</tt> is the parameter associated with the second input
variable and so on. The response to the rule is calculated by:</p>
<pre class="rst-literal-block">
y = a0 + a1*x1 + a2*x2 + ... + an*xn
</pre>
<p>Notice that <tt class="rst-docutils literal">mx</tt>'s are <em>functions</em> not fuzzy sets! They will be applied to
the values of the input variables given in the function call, so, if they
are anything different from a membership function, an exception will be
raised. Please, consult the examples to see how they must be used.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.fuzzy.control.Parametric-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">rules</span>=<span class="summary-sig-default"><code class="variable-group">[</code><code class="variable-group">]</code></span>,
        <span class="summary-sig-arg">norm</span>=<span class="summary-sig-default">&lt;function ProbabilisticAnd at 0xa03e56c&gt;</span>,
        <span class="summary-sig-arg">conorm</span>=<span class="summary-sig-default">&lt;function ProbabilisticOr at 0xa03e5a4&gt;</span>,
        <span class="summary-sig-arg">negation</span>=<span class="summary-sig-default">&lt;function ProbabilisticNot at 0xa03e5dc&gt;</span>)</span><br />
      Creates and initializes the controller.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__getrules"></a><span class="summary-sig-name">__getrules</span>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.__getrules">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.fuzzy.control.Parametric-class.html#add_rule" class="summary-sig-name">add_rule</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">rule</span>)</span><br />
      Adds a decision rule to the knowledge base.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.add_rule">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.fuzzy.control.Parametric-class.html#eval" class="summary-sig-name">eval</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">r</span>,
        <span class="summary-sig-arg">xs</span>)</span><br />
      Evaluates one decision rule in this controller</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.eval">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.fuzzy.control.Parametric-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">*xs</span>)</span><br />
      Apply the controller to the set of input variables</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.__call__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="peach.fuzzy.control.Parametric-class.html#rules" class="summary-name">rules</a><br />
      Property that returns the list of decision rules. Not writable
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">rules</span>=<span class="sig-default"><code class="variable-group">[</code><code class="variable-group">]</code></span>,
        <span class="sig-arg">norm</span>=<span class="sig-default">&lt;function ProbabilisticAnd at 0xa03e56c&gt;</span>,
        <span class="sig-arg">conorm</span>=<span class="sig-default">&lt;function ProbabilisticOr at 0xa03e5a4&gt;</span>,
        <span class="sig-arg">negation</span>=<span class="sig-default">&lt;function ProbabilisticNot at 0xa03e5dc&gt;</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  Creates and initializes the controller.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>rules</code></strong> - List containing the decision rules for the controller. If not given,
an empty set of decision rules is used.</li>
        <li><strong class="pname"><code>norm</code></strong> - The norm (<tt class="rst-docutils literal">and</tt> operation) to be used. Defaults to Probabilistic
and.</li>
        <li><strong class="pname"><code>conorm</code></strong> - The conorm (<tt class="rst-docutils literal">or</tt> operation) to be used. Defaults to Probabilistic
or.</li>
        <li><strong class="pname"><code>negation</code></strong> - The negation (<tt class="rst-docutils literal">not</tt> operation) to be used. Defaults to
Probabilistic not.</li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="add_rule"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">add_rule</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">rule</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.add_rule">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Adds a decision rule to the knowledge base.</p>
<p>It is essential to understand the format that decision rules must follow
to obtain correct behaviour of the controller. A rule is a tuple given
by:</p>
<pre class="rst-literal-block">
((mx0, mx1, ..., mxn), (a0, a1, ..., an))
</pre>
<p>where <tt class="rst-docutils literal">mx0</tt> is a membership function of the first input variable,
<tt class="rst-docutils literal">mx1</tt> is a membership function of the second input variable and so on;
and <tt class="rst-docutils literal">a0</tt> is the linear parameter, <tt class="rst-docutils literal">a1</tt> is the parameter associated
with the first input variable, <tt class="rst-docutils literal">a2</tt> is the parameter associated with
the second input variable and so on.</p>
<p>Notice that <tt class="rst-docutils literal">mx</tt>'s are <em>functions</em> not fuzzy sets! They will be
applied to the values of the input variables given in the function call,
so, if they are anything different from a membership function, an
exception will be raised. Please, consult the examples to see how they
must be used.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="eval"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">eval</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">r</span>,
        <span class="sig-arg">xs</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.eval">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Evaluates one decision rule in this controller</p>
<p>Takes a rule from the controller and evaluates it given the values of
the input variables. The format of the rule is as given, and the
response to the rule is calculated by:</p>
<pre class="rst-literal-block">
y = a0 + a1*x1 + a2*x2 + ... + an*xn
</pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>r</code></strong> - The rule in the standard format, or an integer number. If <tt class="rst-docutils literal">r</tt> is
an integer, then the <tt class="rst-docutils literal">r</tt> th rule in the knowledge base will be
evaluated.</li>
        <li><strong class="pname"><code>xs</code></strong> - A tuple, a list or an array containing the values of the input
variables. The dimension must be coherent with the given rule.</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>This method evaluates each membership function in the rule for each
given value, and <tt class="rst-docutils literal">and</tt> 's the results to obtain the condition. If
the condition is zero, a tuple <tt class="rst-docutils literal">(0.0, 0.0) is returned. Otherwise,
the result as given above is calculate, and a tuple containing
<span class="pre">``(condition,</span> result)</tt> (the membership value associated to the
condition and the result of the calculation) is returned.</dd>
  </dl>
</td></tr></table>
</div>
<a name="__call__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">*xs</span>)</span>
    <br /><em class="fname">(Call operator)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.fuzzy.control-pysrc.html#Parametric.__call__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Apply the controller to the set of input variables</p>
<p>Given the values of the input variables, evaluates every decision rule,
and calculates the weighted average of the results. Returns the response
of the controller.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>xs</code></strong> - A tuple, a list or an array with the values of the input variables.</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>The response of the controller.</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== PROPERTY DETAILS ==================== -->
<a name="section-PropertyDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Property Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-PropertyDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="rules"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">rules</h3>
  Property that returns the list of decision rules. Not writable
  <dl class="fields">
    <dt>Get Method:</dt>
    <dd class="value"><span class="summary-sig"><a href="peach.fuzzy.control.Parametric-class.html#__getrules" class="summary-sig-name" onclick="show_private();">__getrules</a>(<span class="summary-sig-arg">self</span>)</span>
    </dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="peach-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a href="http://code.google.com/p/peach">Peach - Computational Intelligence for Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul 31 16:59:33 2011
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
